package com.front.bean;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

import com.front.web.shiro.service.UserService;

public class InitUserStatusBean implements ApplicationListener<ContextRefreshedEvent>
{
    /**
     * 系统启动初始化用户在线状态
     */
    @Autowired
    private UserService UserService;
  
	public void init() {
		UserService.initUserOnlineStatus();
	}


	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		  ApplicationContext ac = event.getApplicationContext();
	      if(ac!=null&&ac.getParent()==null)
		  {
	    	  init();
		  }
	}
}
